home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
CENVIW1.ZIP
/
MSGBOX.LIB
< prev
next >
Wrap
Text File
|
1993-06-25
|
4KB
|
61 lines
// MsgBox.lib - Cmm code wrapper for the MessageBox function. This library
// can be included in your source file to provide access to
// to Windows' MessageBox() function. The Windows MessageBox()
// function takes a parent window handle as the first paramter,
// but this wrapper simplifies it by automatically selecting
// NULL as the parent window, which is OK for a modal function.
//
// FUNCTION: MessageBox()
// SYNTAX: MessageBox(MessageText[,BoxTitle[,TypeFlags]])
// MessageText: Text string to display in the message box.
// BoxTitle: Title to display on the box. If NULL or this parameter is
// not supplied then Windows defaults to the string "Error"
// TypeFlags: a number of flags, or'ed together to specify the behavior
// of the message box. If this parameter is not supplied then
// it defaults to MB_OK | MB_TASKMODAL. Possible flags are:
#define MB_OK 0x0000 // Message box contains one push button: OK.
#define MB_OKCANCEL 0x0001 // Message box contains two push buttons: OK and Cancel.
#define MB_ABORTRETRYIGNORE 0x0002 // Message box contains three push buttons: Abort, Retry, and Ignore.
#define MB_YESNOCANCEL 0x0003 // Message box contains three push buttons: Yes, No, and Cancel.
#define MB_YESNO 0x0004 // Message box contains two push buttons: Yes and No.
#define MB_RETRYCANCEL 0x0005 // Message box contains two push buttons: Retry and Cancel.
#define MB_ICONSTOP 0x0010 // A stop sign icon appears in the message box.
#define MB_ICONHAND 0x0010 // Same as MB_ICONSTOP.
#define MB_ICONQUESTION 0x0020 // A question-mark icon appears in the message box.
#define MB_ICONEXCLAMATION 0x0030 // An exclamation-point icon appears in the message box.
#define MB_ICONINFORMATION 0x0040 // An icon consisting of a lowercase i in a circle
// appears in the message box.
#define MB_DEFBUTTON1 0x0000 // First button is the default. This is the default.
#define MB_DEFBUTTON2 0x0100 // Second button is the default.
#define MB_DEFBUTTON3 0x0200 // Third button is the default.
#define MB_APPLMODAL 0x0000 // Must respond to this message box before continuing in this application.
#define MB_SYSTEMMODAL 0x1000 // Must respond to this message box before any application may resume.
#define MB_TASKMODAL 0x2000 // Must respond to this message box before continuing in this application.
// RETURN: Returns zero if there is insufficient memory to create the box;
// otherwise returns one of these values:
#define IDOK 1 // OK button pressed
#define IDCANCEL 2 // Cancel button pressed
#define IDABORT 3 // Abort button pressed
#define IDRETRY 4 // Retry button pressed
#define IDIGNORE 5 // Ignore button pressed
#define IDYES 6 // Yes button pressed
#define IDNO 7 // "No" button pressed
MessageBox(MessageText,BoxTitle,TypeFlags)
{
// BoxTitle and TypeFlags are optional, and so check for their existence
// or else take defaults
ParameterCount = va_arg();
mbTitle = ( ParameterCount < 2 ) ? NULL : BoxTitle ;
mbFlags = ( ParameterCount < 3 ) ? (MB_OK | MB_TASKMODAL) : TypeFlags ;
// use DynamicLink to call the MessageBox() routine.
mbResult = ( mbTitle == NULL )
? DynamicLink("USER","MESSAGEBOX",SWORD16,PASCAL,
NULL,MessageText,0,0,mbFlags)
: DynamicLink("USER","MESSAGEBOX",SWORD16,PASCAL,
NULL,MessageText,mbTitle,mbFlags);
return(mbResult);
}